package com.powerwyx.shortlink.project;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

/**
 * @author 王艺锡
 * @version 1.0
 */
@SpringBootApplication
@EnableDiscoveryClient
@MapperScan("com.powerwyx.shortlink.project.mapper")
public class ShortLinkApplication {
    public static void main(String[] args) {
        SpringApplication.run(ShortLinkApplication.class,args);
    }

    /**
     * RabbitMQ的消息序列化器，可用于传输对象
     */
    @Bean
    public MessageConverter jackson2JsonMessageConverter() {
        //定义消息转换器
        Jackson2JsonMessageConverter jjmc = new Jackson2JsonMessageConverter();
        //配置自动创建消息id，用于识别不同消息
        jjmc.setCreateMessageIds(true);
        return jjmc;
    }

}
